package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.PAnswersMapper;
import com.ruoyi.system.domain.PAnswers;
import com.ruoyi.system.service.IPAnswersService;

/**
 * 维修问答Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-03-23
 */
@Service
public class PAnswersServiceImpl implements IPAnswersService 
{
    @Autowired
    private PAnswersMapper pAnswersMapper;

    /**
     * 查询维修问答
     * 
     * @param id 维修问答主键
     * @return 维修问答
     */
    @Override
    public PAnswers selectPAnswersById(Long id)
    {
        return pAnswersMapper.selectPAnswersById(id);
    }

    /**
     * 查询维修问答列表
     * 
     * @param pAnswers 维修问答
     * @return 维修问答
     */
    @Override
    public List<PAnswers> selectPAnswersList(PAnswers pAnswers)
    {
        return pAnswersMapper.selectPAnswersList(pAnswers);
    }

    /**
     * 新增维修问答
     * 
     * @param pAnswers 维修问答
     * @return 结果
     */
    @Override
    public int insertPAnswers(PAnswers pAnswers)
    {
        pAnswers.setCreateTime(DateUtils.getNowDate());
        return pAnswersMapper.insertPAnswers(pAnswers);
    }

    /**
     * 修改维修问答
     * 
     * @param pAnswers 维修问答
     * @return 结果
     */
    @Override
    public int updatePAnswers(PAnswers pAnswers)
    {
        pAnswers.setUpdateTime(DateUtils.getNowDate());
        return pAnswersMapper.updatePAnswers(pAnswers);
    }

    /**
     * 批量删除维修问答
     * 
     * @param ids 需要删除的维修问答主键
     * @return 结果
     */
    @Override
    public int deletePAnswersByIds(Long[] ids)
    {
        for (Long id:ids){
            PAnswers pAnswers = pAnswersMapper.selectPAnswersById(id);
            pAnswers.setDelFlag("1");
            pAnswersMapper.updatePAnswers(pAnswers);
        }
        return ids.length;
    }

    /**
     * 删除维修问答信息
     * 
     * @param id 维修问答主键
     * @return 结果
     */
    @Override
    public int deletePAnswersById(Long id)
    {
        PAnswers pAnswers = pAnswersMapper.selectPAnswersById(id);
        pAnswers.setDelFlag("1");
        return pAnswersMapper.updatePAnswers(pAnswers);
    }
}
